using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.U2D;

namespace Elvex
{
    public static class Sprites
    {
        public static Sprite Load(string asset)
        {
            return Assets.Load<Sprite>(asset);
        }

        public static Sprite Load(string asset, string name)
        {
            if (".spriteatlas" == Path.GetExtension(asset))
            {
                var atlas = Assets.Load<SpriteAtlas>(asset);
                if (null == atlas)
                {
                    Debug.LogErrorFormat("Sprite({0}) Load Fail.", asset);
                    return null;
                }
                return atlas.GetSprite(name);
            }
            else
            {
                return Assets.Load<Sprite>(asset, name);
            }
        }
    }
}


